package com.jmy.service.impl;

import com.jmy.mapper.AdminMapper;
import com.jmy.pojo.Admin;
import com.jmy.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author: VE
 * @DATE: 2022/9/27 14:06
 * 描述:
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public Object insert(Admin admin) {
        return null;
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public Object delete(int id) {
        return null;
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public Object update(Admin admin) {
        return null;
    }
    @Transactional(readOnly = true)
    @Override
    public Admin load(int id) {
        return null;
    }
    @Transactional(readOnly = true)
    @Override
    public Admin getAdminByName(String aName) {
        return adminMapper.getAdminByName(aName);
    }
    @Transactional(readOnly = true)
    @Override
    public List<Admin> getAdminList() {
        return adminMapper.getAdminList();
    }
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void updateAdminRoles(Integer aid, String[] roles) {
        adminMapper.deleteAdminRoles(aid);

        adminMapper.addAdminRoles(aid,roles);
    }
}
